<template>
  <div>
    <div>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item :to="{ path: $route.path }">{{ $route.meta.title }}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
<!--    <div>-->
<!--      <el-breadcrumb separator="/">-->
<!--        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>-->
<!--        <el-breadcrumb-item><a href="/">活动管理</a></el-breadcrumb-item>-->
<!--      </el-breadcrumb>-->
<!--    </div>-->
      <el-select v-model="value" placeholder="请选择要搜索的字段" size="mini">
        <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value">
        </el-option>
      </el-select>
      <!--  搜索-->
      <el-input v-model="search" placeholder="请输入要查询的字段的值" style="width: 20%;margin-left: 10px" size="mini"></el-input>
      <el-button type="primary" style="margin-top: 10px;margin-left: 10px" @click="ShowSearch()" icon="el-icon-search" size="mini">查询</el-button>
    <div style="margin-top: 10px;margin-bottom: 10px">
      <el-button
          size="mini"
          type="primary"
          class="handle-del mr10"
          style="width: 160px"
          @click="ShowAllET()"
      >展示所有数据</el-button>
      <el-button
          size="mini"
          type="primary"
          class="handle-del mr10"
          @click="SchoolETAdd()"
          icon="el-icon-circle-plus-outline"
          style="width: 160px"
      >添加评估任务</el-button>
      <el-button
          size="mini"
          type="primary"
          class="handle-del mr10"
          style="width: 160px"
          @click="Export()"
          icon="el-icon-download"
      >导出</el-button>
    </div>
    <el-table
        size="mini"
        :row-style="{height:'10px'}"
        :cell-style="{padding:'0px'}"
        :data=this.tableData
        border
        :header-cell-style="{background:'lightblue',color:'#262626'}"
        style="width: 1366px">
      <el-table-column
          prop="evaluatetaskid"
          label="评估任务号"
          align="center"
          width="95">
      </el-table-column>
      <el-table-column
          prop="evaluatetaskname"
          label="评估任务名称"
          align="center"
          width="150">
      </el-table-column>
      <el-table-column
          prop="evaluateid"
          label="评估号"
          align="center"
          width="80">
      </el-table-column>
      <el-table-column
          prop="evaluatetaskopentime"
          label="评估任务开始时间"
          align="center"
          width="180">
      </el-table-column>
      <el-table-column
          prop="evaluatetaskendtime"
          label="评估任务结束时间"
          align="center"
          width="180">
      </el-table-column>
      <el-table-column
          prop="evaluatetaskcontent"
          label="评估任务内容"
          align="center"
          width="300">
      </el-table-column>
      <el-table-column
          prop="selectedschoolnumber"
          label="已选学校数"
          align="center"
          width="80">
      </el-table-column>
      <el-table-column
          prop="evaluateattitude"
          label="是否过期/开始"
          align="center"
          width="100">
      </el-table-column>
      <el-table-column
          label="操作"
          align="center"
          width="150">
        <template slot-scope="scope">
          <el-button @click="send(scope.row)" type="text" size="small">选择学校</el-button>
          <el-button @click="edit(scope.row),dialogFormVisible = true" type="text" size="small">修改</el-button>
          <el-button @click="del(scope.row)" type="text" size="small">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-table
        :data=this.tableData1
        border
        hidden
        id="out-table1"
        :header-cell-style="{background:'lightblue',color:'#262626'}"
        style="width: 1266px">
      <el-table-column
          prop="evaluatetaskid"
          label="评估任务号"
          width="95">
      </el-table-column>
      <el-table-column
          prop="evaluatetaskname"
          label="评估任务名称"
          width="150">
      </el-table-column>
      <el-table-column
          prop="evaluateid"
          label="评估号"
          width="80">
      </el-table-column>
      <el-table-column
          prop="evaluatetaskopentime"
          label="评估任务开始时间"
          width="180">
      </el-table-column>
      <el-table-column
          prop="evaluatetaskendtime"
          label="评估任务结束时间"
          width="180">
      </el-table-column>
      <el-table-column
          prop="evaluatetaskcontent"
          label="评估任务内容"
          width="300">
      </el-table-column>
      <el-table-column
          prop="selectedschoolnumber"
          label="已选择的学校数量"
          width="80">
      </el-table-column>
    </el-table>
    <el-pagination
        background
        style="margin-top: 10px"
        align="center"
        layout="prev, pager, next"
        page-size="20"
        :total="total"
        v-show="isShow"
        hide-on-single-page
        @current-change="page">
    </el-pagination>
    <el-dialog :title=this.modeName :visible.sync="dialogFormVisible" :show-close=false width="950px">
      <hr style="margin-top: -30px;margin-bottom: 10px">
      <el-form :model="ruleForm" :rules="rules" :inline="true" ref="ruleForm" label-width="180px" class="demo-ruleForm">
        <el-form-item label="评估任务号" prop="evaluatetaskid">
          <el-input v-model="ruleForm.evaluatetaskid"></el-input>
        </el-form-item>
        <el-form-item label="评估任务名称" prop="evaluatetaskname">
          <el-input v-model="ruleForm.evaluatetaskname"></el-input>
        </el-form-item>
        <el-form-item label="评估号" prop="evaluateid">
          <el-input v-model="ruleForm.evaluateid"></el-input>
        </el-form-item>
        <el-form-item label="评估任务开始时间" prop="evaluatetaskopentime">
          <el-date-picker
              v-model="ruleForm.evaluatetaskopentime"
              type="datetime"
              placeholder="选择日期时间"
              align="right"
              :picker-options="pickerOptions"
              @change="transOpen">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="评估任务结束时间" prop="evaluatetaskendtime">
          <el-date-picker
              v-model="ruleForm.evaluatetaskendtime"
              type="datetime"
              placeholder="选择日期时间"
              align="right"
              :picker-options="pickerOptions"
              @change="transEnd">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="评估任务内容" prop="evaluatetaskcontent">
          <el-input v-model="ruleForm.evaluatetaskcontent"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm('ruleForm'),allid=''">确定</el-button>
<!--        <el-button @click="resetForm('ruleForm')">重置</el-button>-->
        <el-button @click="dialogFormVisible = false,allid=''">取 消</el-button>
        <!--        <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>-->
      </div>
    </el-dialog>
    <el-dialog title="选择学校" :visible.sync="dialogFormVisible2" :show-close=false width="950px">
      <hr style="margin-top: -30px;margin-bottom: 10px">
      <el-transfer
          style="text-align: left; display: inline-block;"
          v-model="value4"
          filterable
          :right-default-checked="[value4]"
          :render-content="renderFunc"
          :titles="['未选择的学校', '已选择的学校']"
          :button-texts="['取消选择', '选择学校']"
          :format="{
        noChecked: '${total}',
        hasChecked: '${checked}/${total}'
      }"
          @change="handleChange"
          :data="data">
      </el-transfer>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="returnToTable">确定</el-button>
<!--        <el-button @click="resetForm('ruleForm')">重置</el-button>-->
        <el-button @click="returnToTable">取 消</el-button>
        <!--        <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>-->
      </div>
    </el-dialog>

  </div>
</template>
<script>
export default {
  methods:{
    page(currentPage){
      const _this=this
      this.returnPage=currentPage
      axios.get('http://localhost:8081/evaluatetask/page?current='+currentPage+'&size=20').then(function (res) {
        // console.log(res.data)
        // _this.tableData = res.data.evaluatetaskList;
        // _this.total = res.data.total;
        let etlen=res.data.length
        while (etlen){
          etlen--
          res.data.evaluatetaskList[etlen].evaluatetaskopentime=_this.$moment(res.data.evaluatetaskList[etlen].evaluatetaskopentime).format('YYYY-MM-DD HH:mm:ss')
          res.data.evaluatetaskList[etlen].evaluatetaskendtime=_this.$moment(res.data.evaluatetaskList[etlen].evaluatetaskendtime).format('YYYY-MM-DD HH:mm:ss')
          let time=new Date().getTime()
          let ot=new Date(res.data.evaluatetaskList[etlen].evaluatetaskopentime).getTime()
          let et=new Date(res.data.evaluatetaskList[etlen].evaluatetaskendtime).getTime()
          if  (time>=et){
            //已结束
            res.data.evaluatetaskList[etlen].evaluateattitude='已过期'
          }
          else if (time<et && time >=ot){
            //进行中
            res.data.evaluatetaskList[etlen].evaluateattitude='进行中'
          }
          else {
            //未开始
            res.data.evaluatetaskList[etlen].evaluateattitude='未开始'
          }
        }
        _this.tableData=res.data.evaluatetaskList
        _this.tableData1=res.data.evaluatetaskList
        // _this.returnPage=res.data.current+1;
        _this.total=res.data.total;
      })
    },
    submitForm(formName) {
      const _this=this
      this.$refs[formName].validate((valid) => {
        if (valid) {
          if(this.allid){
            axios.put("http://localhost:8081/evaluatetask/update",this.ruleForm).then(function (res){
              if (res.data.msg==="更新成功"){
                _this.$message({
                  message: '更新成功！',
                  type: 'success'
                  //添加成功后页面跳转
                });
                _this.dialogFormVisible=false
                // axios.get('http://localhost:8081/evaluatetask/findAll').then(function (res){
                //   let etlen=res.data.length
                //   while (etlen){
                //     etlen--
                //     res.data[etlen].evaluatetaskopentime=_this.$moment(res.data[etlen].evaluatetaskopentime).format('YYYY-MM-DD HH:mm:ss')
                //     res.data[etlen].evaluatetaskendtime=_this.$moment(res.data[etlen].evaluatetaskendtime).format('YYYY-MM-DD HH:mm:ss')
                //   }
                //   _this.tableData=res.data
                // })
                axios.get('http://localhost:8081/evaluatetask/findAll').then(function (res){
                  let etlen=res.data.length
                  while (etlen){
                    etlen--
                    res.data[etlen].evaluatetaskopentime=_this.$moment(res.data[etlen].evaluatetaskopentime).format('YYYY-MM-DD HH:mm:ss')
                    res.data[etlen].evaluatetaskendtime=_this.$moment(res.data[etlen].evaluatetaskendtime).format('YYYY-MM-DD HH:mm:ss')
                    let time=new Date().getTime()
                    let ot=new Date(res.data[etlen].evaluatetaskopentime).getTime()
                    let et=new Date(res.data[etlen].evaluatetaskendtime).getTime()
                    if  (time>=et){
                      //已结束
                      res.data[etlen].evaluateattitude='已过期'
                    }
                    else if (time<et && time >=ot){
                      //进行中
                      res.data[etlen].evaluateattitude='进行中'
                    }
                    else {
                      //未开始
                      res.data[etlen].evaluateattitude='未开始'
                    }
                  }

                  _this.tableData=res.data
                  _this.tableData1=res.data
                })
              }
              else{
                _this.$message({
                  message: '评估任务号重复或者评估号不存在！请重新输入',
                  type: 'fail'
                });
              }
            })
          }
          else {
            axios.post("http://localhost:8081/evaluatetask/save",this.ruleForm).then(function (res){
              if (res.data.msg==="添加成功"){
                _this.$message({
                  message: '添加成功！',
                  type: 'success'
                  //添加成功后页面跳转
                });
                // _this.$router.push('/EvaluateTaskList')
                _this.dialogFormVisible=false
                // axios.get('http://localhost:8081/evaluatetask/findAll').then(function (res){
                //   let etlen=res.data.length
                //   while (etlen){
                //     etlen--
                //     res.data[etlen].evaluatetaskopentime=_this.$moment(res.data[etlen].evaluatetaskopentime).format('YYYY-MM-DD HH:mm:ss')
                //     res.data[etlen].evaluatetaskendtime=_this.$moment(res.data[etlen].evaluatetaskendtime).format('YYYY-MM-DD HH:mm:ss')
                //   }
                //   _this.tableData=res.data
                // })
                axios.get('http://localhost:8081/evaluatetask/findAll').then(function (res){
                  let etlen=res.data.length
                  while (etlen){
                    etlen--
                    res.data[etlen].evaluatetaskopentime=_this.$moment(res.data[etlen].evaluatetaskopentime).format('YYYY-MM-DD HH:mm:ss')
                    res.data[etlen].evaluatetaskendtime=_this.$moment(res.data[etlen].evaluatetaskendtime).format('YYYY-MM-DD HH:mm:ss')
                    let time=new Date().getTime()
                    let ot=new Date(res.data[etlen].evaluatetaskopentime).getTime()
                    let et=new Date(res.data[etlen].evaluatetaskendtime).getTime()
                    if  (time>=et){
                      //已结束
                      res.data[etlen].evaluateattitude='已过期'
                    }
                    else if (time<et && time >=ot){
                      //进行中
                      res.data[etlen].evaluateattitude='进行中'
                    }
                    else {
                      //未开始
                      res.data[etlen].evaluateattitude='未开始'
                    }
                  }

                  _this.tableData=res.data
                  _this.tableData1=res.data
                })
              }
              else{
                _this.$message({
                  message: '评估任务号重复或评估号不存在！请重新输入',
                  type: 'fail'
                });
              }
            })
          }
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
    ShowAllET(){
      const _this=this
      // axios.get('http://localhost:8081/evaluatetask/findAll').then(function (res){
      //   _this.tableData=res.data
      // })
      axios.get('http://localhost:8081/evaluatetask/findAll').then(function (res){
        let etlen=res.data.length
        while (etlen){
          etlen--
          res.data[etlen].evaluatetaskopentime=_this.$moment(res.data[etlen].evaluatetaskopentime).format('YYYY-MM-DD HH:mm:ss')
          res.data[etlen].evaluatetaskendtime=_this.$moment(res.data[etlen].evaluatetaskendtime).format('YYYY-MM-DD HH:mm:ss')
        }
        _this.tableData=res.data
        _this.tableData1=res.data
        // console.log(_this.tableData)
      })
    },
    ShowSearch(){
      const _this=this
      axios.get("http://localhost:8081/evaluatetask/search/"+this.value+'/'+this.search).then(function (res){
        _this.tableData=res.data
        _this.search=''
      })
    },
    Export(){
      let tables = document.getElementById("out-table1");
      console.log(tables)
      let table_book = this.$XLSX.utils.table_to_book(tables);
      var table_write = this.$XLSX.write(table_book, {
        bookType: "xlsx",
        bookSST: true,
        type: "array"
      });
      try {
        this.$FileSaver.saveAs(
            new Blob([table_write], { type: "application/octet-stream" }),
            "EvaluateTask.xlsx"
        );
      } catch (e) {
        if (typeof console !== "undefined") console.log(e, table_write);
      }
      return table_write;
    },
    SchoolETAdd(){
      this.dialogFormVisible = true;
      this.modeName='添加评估任务'
      this.ruleForm={}
    },
    edit(row){
      this.dialogFormVisible = true
      this.modeName='更新评估任务'
      this.ruleForm=row
      this.allid=row.id
    },
    send(row){
      this.existSchoolName=[]
      this.value4=[]
      this.allid=row.id
      this.eid=row.evaluatetaskid
      this.dialogFormVisible2 = true
      this.dateAttitude=row.evaluateattitude
      console.log(this.datacopy)
      let len=0
      axios.get("http://localhost:8081/evaluatetaskarrange/search/1/"+this.eid).then((res)=>{
        len=res.data.length;
        while(len){
          len--;
          this.existSchoolName.push(
              res.data[len].schoolname
          )
        }
        for (let j=0;j<this.existSchoolName.length;j++){
          for (let k=0;k<this.datalen;k++){
            if (this.existSchoolName[j]===this.datacopy[k].label){
              this.value4.push(this.datacopy[k].key)
            }
          }
        }
      })
    },
    del(row){
      const _this=this
      const d=confirm("确定删除吗？");
      if (d){
        axios.delete('http://localhost:8081/evaluatetask/delete/'+row.id).then(()=>{
          alert("删除成功")
          // location.reload();
          // this.ShowAllET()
          axios.get('http://localhost:8081/evaluatetask/findAll').then(function (res){
            let etlen=res.data.length
            while (etlen){
              etlen--
              res.data[etlen].evaluatetaskopentime=_this.$moment(res.data[etlen].evaluatetaskopentime).format('YYYY-MM-DD HH:mm:ss')
              res.data[etlen].evaluatetaskendtime=_this.$moment(res.data[etlen].evaluatetaskendtime).format('YYYY-MM-DD HH:mm:ss')
              let time=new Date().getTime()
              let ot=new Date(res.data[etlen].evaluatetaskopentime).getTime()
              let et=new Date(res.data[etlen].evaluatetaskendtime).getTime()
              if  (time>=et){
                //已结束
                res.data[etlen].evaluateattitude='已过期'
              }
              else if (time<et && time >=ot){
                //进行中
                res.data[etlen].evaluateattitude='进行中'
              }
              else {
                //未开始
                res.data[etlen].evaluateattitude='未开始'
              }
            }

            _this.tableData=res.data
            _this.tableData1=res.data
          })
        })
      }
    },
    transEnd(){
      this.ruleForm.evaluatetaskendtime=this.$moment(this.ruleForm.evaluatetaskendtime).format('YYYY-MM-DD HH:mm:ss')
    },
    transOpen(){
      this.ruleForm.evaluatetaskopentime=this.$moment(this.ruleForm.evaluatetaskopentime).format('YYYY-MM-DD HH:mm:ss')
    },
    handleChange(value, direction, movedKeys) {
      if (direction==="right"){
        //如果向右移动 则加入数据库
        // console.log(this.data[movedKeys[0]].label)
        for (let ii=0;ii<movedKeys.length;ii++){
          let newInsert={evaluatetaskid: this.eid,schoolname:this.data[movedKeys[ii]].label,isfinished:'否',isevaluated:'否',evaluateattitude:this.dateAttitude}
          console.log(newInsert)
          axios.post("http://localhost:8081/evaluatetaskarrange/save",newInsert).then((res)=>{
            // console.log(newInsert)
            if (res.data.msg==="发布成功"){
              this.$message({
                message: '添加成功！',
                type: 'success'
                //添加成功后页面跳转
              });
              axios.get("http://localhost:8081/evaluatetask/selectone/"+this.allid).then((res)=>{
                let info=res.data
                info.selectedschoolnumber=this.value4.length
                console.log(info)
                axios.put("http://localhost:8081/evaluatetask/update",info).then((res)=>{
                  if (res.data.msg==="更新成功"){
                  }
                  else{
                    this.$message({
                      message: '评估任务号重复或者评估号不存在！请重新输入',
                      type: 'fail'
                    });
                  }
                })
              })
            }
            else{
              this.$message({
                message: '评估号重复！请重新输入',
                type: 'fail'
              });
            }
          })

        }
      }
      if (direction==="left"){
        //如果向左移动 则从数据库中删除
        for (let jj=0;jj<movedKeys.length;jj++){
          axios.delete('http://localhost:8081/evaluatetaskarrange/delete/2/'+this.data[movedKeys[jj]].label).then(()=>{
            this.$message({
              message: '取消成功！',
              type: 'success'
              //添加成功后页面跳转
            });
            axios.get("http://localhost:8081/evaluatetask/selectone/"+this.allid).then((res)=>{
              let info=res.data
              info.selectedschoolnumber=this.value4.length
              axios.put("http://localhost:8081/evaluatetask/update",info).then((res)=>{
                if (res.data.msg==="更新成功"){
                }
                else{
                  this.$message({
                    message: '评估任务号重复或者评估号不存在！请重新输入',
                    type: 'fail'
                  });
                }
              })
            })
          })
        }
      }
    },
    returnToTable(){
      this.dialogFormVisible2 = false
      this.ShowAllET()
    }
  },
  // computed: {
  //   breadNav () {
  //     return this.$route.meta.title
  //   }
  // },
  data(){
    const generateData = _ => {
      const data = [];
      let len=0;
      axios.get("http://localhost:8081/school/findAll").then((res)=>{
        len=res.data.length;
        console.log(res.data)
        this.datalen=len
        for (let i = 0; i < len; i++) {
          data.push({
            key: i,
            label: res.data[i].schoolname,
          });
        }
        this.datacopy=data;
      })
      return data;
    };
    return {
      data: generateData(),
      datacopy:[],
      datalen:0,
      eid:'',
      value4: [],
      existSchoolName:[],
      renderFunc(h, option) {
        return <span>{ option.label }</span>;
      },
      search:'',
      allid:'',
      mode:'',
      dateAttitude:'',
      isShow:true,
      modeName:'',
      options: [{
        value: '1',
        label: '评估任务号'
      }, {
        value: '2',
        label: '评估任务名称'
      },
        {
          value: '3',
          label: '评估名称'
        },
        {
          value: '4',
          label: '评估任务开始时间'
        },
        {
          value: '5',
          label: '评估任务结束时间'
        },
        {
          value: '6',
          label: '评估任务内容'
        },
      ],
      value: '',
      total:null,
      tableData: null,
      tableData1: null,
      testdata:'',
      returnPage:'',
      dataList: [],
      fileList: [],
      query: {"page":0, "size":20, count:0},
      column: [
        {label: "序号", prop: "id", type: "string"},
        {label: "评估任务号", prop: "evaluatetaskid", type: "string"},
        {label: "评估任务名称", prop: "evaluatetaskname", type: "string"},
        {label: "评估号", prop: "evaluateid", type: "string"},
        {label: "评估任务开始时间", prop: "evaluatetaskopentime", type: "string"},
        {label: "评估任务结束时间", prop: "evaluatetaskendtime", type: "string"},
        {label: "评估任务内容", prop: "evaluatetaskcontent", type: "string"},
      ],
      editForm: {},
      editVisible: false,
      currentIndex: null,
      ruleForm: {
        // id:'',
        evaluatetaskid: '',
        evaluatetaskname: '',
        evaluateid:'',
        evaluatetaskopentime:'',
        evaluatetaskendtime:'',
        evaluatetaskcontent:'',
      },
      rules: {
        id: [
          { required: true, message: '请填写编号 注意与已存在的编号不要重复', trigger: 'blur' }
        ],
        evaluatetaskid: [
          { required: true, message: '请填写评估任务号', trigger: 'blur' }
        ],
        evaluatetaskname: [
          { required: true, message: '请填写评估任务名称', trigger: 'blur' }
        ],
        evaluateid: [
          { required: true, message: '请填写评估号', trigger: 'blur' }
        ],
        evaluatetaskopentime: [
          { required: true, message: '请填写评估任务开始时间', trigger: 'blur' }
        ],
        evaluatetaskendtime: [
          { required: true, message: '请填写评估任务结束时间', trigger: 'blur' }
        ],
        evaluatetaskcontent: [
          { required: true, message: '请填写评估任务内容', trigger: 'blur' }
        ],
      },
      dialogTableVisible: false,
      dialogFormVisible: false,
      dialogFormVisible2: false,
      formLabelWidth: '120px',
    }
  },
  created() {
      const _this=this
      const a=localStorage.getItem("access-expert")
      let len=0
      if(a){
        // axios.get('http://localhost:8081/evaluatetask/findAll').then(function (res){
        //   let etlen=res.data.length
        //   while (etlen){
        //     etlen--
        //     res.data[etlen].evaluatetaskopentime=_this.$moment(res.data[etlen].evaluatetaskopentime).format('YYYY-MM-DD HH:mm:ss')
        //     res.data[etlen].evaluatetaskendtime=_this.$moment(res.data[etlen].evaluatetaskendtime).format('YYYY-MM-DD HH:mm:ss')
        //     let time=new Date().getTime()
        //     let ot=new Date(res.data[etlen].evaluatetaskopentime).getTime()
        //     let et=new Date(res.data[etlen].evaluatetaskendtime).getTime()
        //     if  (time>=et){
        //       //已结束
        //       res.data[etlen].evaluateattitude='已过期'
        //     }
        //     else if (time<et && time >=ot){
        //       //进行中
        //       res.data[etlen].evaluateattitude='进行中'
        //     }
        //     else {
        //       //未开始
        //       res.data[etlen].evaluateattitude='未开始'
        //     }
        //   }
        //   _this.tableData=res.data
        //   _this.tableData1=res.data
        // })
        axios.get('http://localhost:8081/evaluatetask/page?current=0&size=20').then(function (res){
          let etlen=res.data.evaluatetaskList.length
          while (etlen){
            etlen--
            res.data.evaluatetaskList[etlen].evaluatetaskopentime=_this.$moment(res.data.evaluatetaskList[etlen].evaluatetaskopentime).format('YYYY-MM-DD HH:mm:ss')
            res.data.evaluatetaskList[etlen].evaluatetaskendtime=_this.$moment(res.data.evaluatetaskList[etlen].evaluatetaskendtime).format('YYYY-MM-DD HH:mm:ss')
            let time=new Date().getTime()
            let ot=new Date(res.data.evaluatetaskList[etlen].evaluatetaskopentime).getTime()
            let et=new Date(res.data.evaluatetaskList[etlen].evaluatetaskendtime).getTime()
            if  (time>=et){
              //已结束
              res.data.evaluatetaskList[etlen].evaluateattitude='已过期'
            }
            else if (time<et && time >=ot){
              //进行中
              res.data.evaluatetaskList[etlen].evaluateattitude='进行中'
            }
            else {
              //未开始
              res.data.evaluatetaskList[etlen].evaluateattitude='未开始'
            }
          }
          _this.tableData=res.data.evaluatetaskList
          _this.tableData1=res.data.evaluatetaskList
          _this.returnPage=res.data.current+1;
          _this.total=res.data.total;
        })

      }
      else{
        this.$alert('未登录','提示',{
          confirmButtonText:'确定'
        }).then((res)=>{
          this.$router.replace({path:'/login'})
        })
      }
  }
}
</script>
<style scoped>
</style>
